#include <51func.h>
int main(int argc, char *argv[])
{
    // ./7_mycp src dst
    ARGS_CHECK(argc,3);
    int fdr = open(argv[1],O_RDONLY);
    ERROR_CHECK(fdr,-1,"open fdr");
    int fdw = open(argv[2],O_WRONLY|O_CREAT|O_TRUNC,0666);
    ERROR_CHECK(fdw,-1,"open fdw");
    char buf[409600];
    while(1){
        memset(buf,0,sizeof(buf));
        ssize_t sret = read(fdr,buf,sizeof(buf));
        if(sret == 0){
            break;
        }
        // sizeof --> 4096
        // strlen --> 有可能是二进制文件 '\0'不是文件的结尾
        write(fdw,buf,sret);
    }
    return 0;
}

